$(function () { $("a[target=_blank]:not(.LoadingOff)").click(function () { return false; }); //tuanha: #mainNav ul ul a, .AccountPage a, $(".LoadingOn, .BackLink, #mainNav ul ul a, .CustomerInfo a, .LangRow a,.SideBar a[target!=_blank]:not(.LoadingOff), .UserAccountPage a").click(loading); var d = new Date(); var date = d.getDate(); permission(); //Renders methods // Submit - call service - Not check input $(".IdCallServiceNotCheckInput").click(function () { // count down $(".CountDownReload").each(function () { var $this = $(this); $this.text("150"); var time = parseInt($this.text()); var i = 0; var int = self.setInterval(function () { $this.text(time - i); if (i > time) { $this.prev().click(); $this.remove(); int = window.clearInterval(int); }; i++; }, 1000); }); // show loading loading(); }); // Submit - call service - check input $(".IdCallService").click(function () { var error = 0; $(".RequiredInput").each(function () { var $this = $(this); if ($this.val() == "") { error++; $this.focus().addClass("Error"); } else { $this.removeClass("Error"); }; }); $(".TextSize35").each(function () { var $this = $(this); if ($this.val().length > 34) { error++; $this.focus().addClass("Error"); } else { $this.removeClass("Error"); }; }); $(".TextSize50").each(function () { var $this = $(this); if ($this.val().length > 49) { error++; $this.focus().addClass("Error"); } else { $this.removeClass("Error"); }; }); $(".TextSize100").each(function () { var $this = $(this); if ($this.val().length > 99) { error++; $this.focus().addClass("Error"); } else { $this.removeClass("Error"); }; }); $(".TextSize150").each(function () { var $this = $(this); if ($this.val().length > 150) { error++; $this.focus().addClass("Error"); } else { $this.removeClass("Error"); }; }); $(".TextSize200").each(function () { var $this = $(this); if ($this.val().length > 199) { error++; $this.focus().addClass("Error"); } else { $this.removeClass("Error"); }; }); if (error > 0) return false; // count down $(".CountDownReload").each(function () { var $this = $(this); $this.text("150"); var time = parseInt($this.text()); var i = 0; var int = self.setInterval(function () { $this.text(time - i); if (i > time) { $this.prev().click(); $this.remove(); int = window.clearInterval(int); }; i++; }, 1000); }); // show loading loading(); }); // $(".Captcha").val(""); $(".TransactionDetails .DataTable").each(function () { if ($("tr", this).length <= 1) $(this).hide(); }); // $(".LPBAcc").each(function () { // var Acc = $(this).text(); // $(this).text(formatAccLPB(Acc)); // }); $(".AccountPage .DataPanel").each(function () { var $this = $(this).clone(); $("tr:not(:first)", $this).remove(); var tr = $("tr", this); var clone = 0; if (tr.length > 10) { tr.each(function () { var ccy = $("td:last", this).text(); if (ccy != "VND" && ccy.length == 3) { $(this).appendTo($("table", $this)); clone++; }; }); if (clone > 0) { $("h3 .VND", $this).hide(); $("h3 .Virtual", $this).show(); $this.appendTo($(this).parent()); }; }; }); $(".ListAccounts").each(function () { sumaryMoney(this); }); if ($("#totalTransferTo").length > 0) calculateTotalTransferTo(); if ($(".Unique:checked").length == 0) $(".Unique:first").attr('checked', 'checked'); $(".FormatMoney, .FormatMoneyLeft, .FormatMoneyRight").each(function () { var $this = $(this); var value = $this.text(); $this.attr('number', value); $this.text(CurrencyFormatted(value)); }); $(".FormatMoney_With_VND").each(function () { var $this = $(this); var value = $this.text(); $this.attr('number', value); $this.text(CurrencyFormatted(value) + " VND"); }); $(".InputMoney").each(function () { value = $(this).val(); value = value.replace(/,/g, '') if (value == "") return false; //value = "0"; value = parseFloat(value); thisMoney = $(this).parent().next().find("span"); money = parseFloat(thisMoney.attr("number")); total = money - value; thisMoney.text(CurrencyFormatted("" + total)); $(this).val(CurrencyFormatted("" + value)); }); //tuanha: 17/5/2017 $(".MoneyInput").keyup(function(event) { // skip for arrow keys if(event.which >= 37 && event.which <= 40) return; // format number $(this).val(function(index, value) { return value .replace(/\D/g, "") .replace(/\B(?=(\d{3})+(?!\d))/g, ",") ; }); //xoa so 0 o dau var inputVal = $(this).val(); if(inputVal.substring(0, 1) == '0' && inputVal.length >= 2){ $(this).val(inputVal.substring(1)); } }); $(".MoneyInput").each(function(event) { $(this).val(function(index, value) { return value .replace(/\D/g, "") .replace(/\B(?=(\d{3})+(?!\d))/g, ",") ; }); }); $(".InputMoney").blur(function () { val = $(this).val(); if (val.charAt(val.length - 1) == ".") return true; value = parseFloat(val.replace(/,/g, '')); thisMoney = $(this).parent().next().find("span"); money = parseFloat(thisMoney.attr("number")); total = money - value; thisMoney.text(CurrencyFormatted("" + total)); calculateTotalTransferTo(); $(this).val(CurrencyFormatted("" + value)); }); $(".InputMoney").keydown(function(event) { // Allow only backspace,delete,left arrow,right arraow and Tab if ( event.keyCode == 46 // delete || event.keyCode == 8 // backspace || event.keyCode == 37 // left arrow || event.keyCode == 39 // right arrow || event.keyCode == 36 // home || event.keyCode == 35 // emd || event.keyCode == 190 // period . (main) || event.keyCode == 110 // period . (numpad) || event.keyCode == 17 // ctrl || event.keyCode == 109 // - || event.keyCode == 9) // tab { // let it happen, don't do anything } else { // Ensure that it is a number and stop the keypress if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode <96 ||event.keyCode > 105) ) { event.preventDefault(); } } }); $(".InputMoney2").each(function () { value = $(this).val(); value = value.replace(/,/g, '') if (value == "") return false; //value = "0"; value = parseFloat(value); thisMoney = $(this).parent().next().find("span"); money = parseFloat(thisMoney.attr("number")); total = money - value; thisMoney.text(CurrencyFormatted("" + total)); $(this).val(CurrencyFormatted("" + value)); }); $(".InputMoney2").blur(function () { val = $(this).val(); if (val.charAt(val.length - 1) == ".") return true; value = parseFloat(val.replace(/,/g, '')); thisMoney = $(this).parent().next().find("span"); money = parseFloat(thisMoney.attr("number")); total = money - value; thisMoney.text(CurrencyFormatted("" + total)); calculateTotalTransferTo(); $(this).val(CurrencyFormatted("" + value)); }); $(".InputMoney2").keydown(function(event) { // Allow only backspace,delete,left arrow,right arraow and Tab if ( event.keyCode == 46 // delete || event.keyCode == 8 // backspace || event.keyCode == 37 // left arrow || event.keyCode == 39 // right arrow || event.keyCode == 36 // home || event.keyCode == 35 // emd || event.keyCode == 17 // ctrl || event.keyCode == 109 // - || event.keyCode == 9) // tab { // let it happen, don't do anything } else { // Ensure that it is a number and stop the keypress if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode <96 ||event.keyCode > 105) ) { event.preventDefault(); } } }); $(".InputMoneyText").blur(function () { val = $(this).val(); value = parseFloat(val.replace(/,/g, '')); if (isNaN(value)){ return true; } if (val.charAt(val.length - 1) == ".") return true; $(this).val(CurrencyFormatted("" + value)); }); $(".RemoveSpecialChar").keydown(function(){ $(this).val($(this).val().replace(/(?!\w|\s)./g, '') .replace(/\s+/g, ' ') .replace(/^(\s*)([\W\w]*)(\b\s*$)/g, '$2')); }); $(".RemoveSpecialChar").blur(function(){ $(this).val($(this).val().replace(/(?!\w|\s)./g, '') .replace(/\s+/g, ' ') .replace(/^(\s*)([\W\w]*)(\b\s*$)/g, '$2')); }); $(".RemoveSpecialChar").keyup(function(){ $(this).val($(this).val().replace(/(?!\w|\s)./g, '') .replace(/\s+/g, ' ') .replace(/^(\s*)([\W\w]*)(\b\s*$)/g, '$2')); }); // DATE FUNCTION /*$(".DatePickerTable input:eq(0)").click(); if($(".radioboxSelected").text() == '1'){ $(".DatePickerTable input:eq(0)").click(); }else if($(".radioboxSelected").text() == '0'){ $(".DatePickerTable input:last").click(); $("#rangeDate").show().addClass("Active"); $("#StatementTerm").hide().removeClass("Active"); } */ var selectRadioTime = $(".DatePickerTable input:last").is(':checked'); if(selectRadioTime){ $("#rangeDate").show().addClass("Active"); } $(".DatePickerTable input:last").change(function () { var d = new Date(); var month = d.getMonth()+1; var day = d.getDate(); var currDate = (day<10 ? '0' : '') + day + '/' + (month<10 ? '0' : '') + month + '/' + d.getFullYear(); $("#rangeDate").show().addClass("Active"); $(".InputDate").val(currDate); $("#StatementTerm").hide().removeClass("Active"); }); $(".DatePickerTable input:not(:last)").change(function () { $("#rangeDate").hide().removeClass("Active"); $(".InputDate").val(''); $("#StatementTerm").show().addClass("Active"); }); // use credit-card $(".DatePickerTable1 input:eq(0)").click(); if($(".radioboxSelected").text() == '1'){ $(".DatePickerTable1 input:eq(1)").click(); }else if($(".radioboxSelected").text() == '0'){ $(".DatePickerTable1 input:eq(2)").click(); $("#rangeDate").show().addClass("Active"); $("#StatementTerm").hide().removeClass("Active"); }else if($(".radioboxSelected").text() == '2'){ $(".DatePickerTable1 input:eq(0)").click(); $("#rangeDate").show().addClass("Active"); $("#StatementTerm").hide().removeClass("Active"); } $(".DatePickerTable1 input:eq(0)").change(function () { $("#rangeDate").show().addClass("Active"); $(".InputDate").val(''); $("#StatementTerm").hide().removeClass("Active"); }); $(".DatePickerTable1 input:eq(1)").change(function () { $("#rangeDate").hide().removeClass("Active"); $(".InputDate").val(''); $("#StatementTerm").show().addClass("Active"); }); $(".DatePickerTable1 input:eq(2)").change(function () { $("#rangeDate").show().addClass("Active"); $(".InputDate").val(''); $("#StatementTerm").hide().removeClass("Active"); }); // END $(".NormalDate .InputDate").datepicker( { dateFormat : 'dd/mm/yy' }); $(".TransDate .InputDate").datepicker( { dateFormat : 'dd/mm/yy', minDate : new Date(), changeMonth : true, changeYear : false, hideIfNoPrevNext : true, gotoCurrent: true }); $(".TransactionOptions .InputDate").datepicker( { dateFormat : 'dd/mm/yy' }); $(".TransferDate .InputDate").datepicker( { dateFormat : 'dd/mm/yy', minDate : new Date(), maxDate : "+1m -" + date + "d", hideIfNoPrevNext : true }); $(".IDDate .InputDate").datepicker( { dateFormat : 'dd/mm/yy', maxDate : new Date(), hideIfNoPrevNext : true, changeMonth : true, changeYear : true, yearRange : 'c-50:c' }); $(".InputDate_Insurance").datepicker( { dateFormat : 'dd/mm/yy' }); // if ($(".CustomBankName").val() != "") { $(".CustomBank").show(); $(".PresetBanks").hide(); }; $("#customBankName").click(function () { $(".CustomBank").show(); $(".PresetBanks").hide(); }); $("#presetBankName").click(function () { $(".CustomBankName").val(""); $(".CustomBank").hide(); $(".PresetBanks").show(); }); if ($(".ExtAccType input:checked").val() == "CMND") { $(".IDGroup").show(); $(".ACCGroup").hide(); }; $(".ExtAccType input").change(function () { if ($(this).val() == "CMND") { $(".IDGroup").show(); $(".ACCGroup").hide(); } else { $(".IDGroup").hide(); $(".ACCGroup").show(); }; }); $('.Unique').on('change', function() { $('.Unique').not(this).prop('checked', false); }); $('.UniqueNoDefault').on('change', function() { $('.UniqueNoDefault').not(this).prop('checked', false); }); $(".future_transfer").click(function () { if ($(this).is(':checked')) { $(".panel_future_transfer").show(); } else { $(".panel_future_transfer").hide(); }; }); $(".Messages").each(function () { if ($(this).text().replace(/(^\s*|\s*$)/, "").length > 5) if ($(this).hasClass("Info")) { $(this).dialog( { autoOpen : true, minHeight : '75px', dialogClass : "InfoMessages" }); } else { $(this).dialog( { autoOpen : true, minHeight : '75px' }); }; }); $(".StatementsTable tr").each(function () { if ($("td:eq(0)", this).text() == "") $(this).addClass("HL"); }); $(".MessageBody").each(function () { var text = this.innerHTML.replace(/</g, "<").replace(/>/g, ">"); $(this).html(text); }); $(".SideBar").wrap('